package com.borya.core;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.apache.log4j.Logger;
import com.borya.framework.annotation.Autowired;
import com.borya.framework.annotation.Component;


@Component("taskExecutorService")
public class TaskExecutorService {
	
	
	private Logger log = Logger.getLogger(getClass());
	@Autowired("redisNotify")
	private RedisNotify redisNotify;
	
	private ScheduledExecutorService service = Executors.newScheduledThreadPool(1);
	
	public final void process(){
		processRedisNotify();
	}
	
	private void processRedisNotify() {
		// 延迟执行一次
		service.schedule(new Runnable() {
			public void run() {
				log.debug("start process");
				redisNotify.process();
			}
		}, 20, TimeUnit.SECONDS);
	}
	
}